#ifndef __MY_I2C_H__
#define __MY_I2C_H__

#include "stm32f10x.h"
#include "delay.h"

#define I2C_PORT            GPIOB
#define I2C_SCL_Pin         GPIO_Pin_6
#define I2C_SDA_Pin         GPIO_Pin_7

#define I2C_SDA_H           GPIOB->BSRR = I2C_SDA_Pin
#define I2C_SDA_L           GPIOB->BRR = I2C_SDA_Pin

#define I2C_SCL_H           GPIOB->BSRR = I2C_SCL_Pin
#define I2C_SCL_L           GPIOB->BRR = I2C_SCL_Pin

void I2C_GPIO_Init(void);

void I2C_Start(void);
void I2C_Stop(void);
void I2C_SendByte(uint8_t data);
uint8_t I2C_ReadByte(uint8_t ack);
uint8_t I2C_SDA_Read(void);

uint8_t I2C_WaitAck(void);
void I2C_Send_Ack_Mater(void);
void I2C_Send_NAck_Mater(void);


uint8_t I2C_ReadMultByteFromSlave(uint8_t dev, uint8_t reg, uint8_t length, uint8_t *data);
uint8_t I2C_ReadByteFromSlave(uint8_t I2C_Addr, uint8_t reg,uint8_t *buf);
uint8_t I2C_WriteMultByteToSalve(uint8_t dev, uint8_t reg, uint8_t length, uint8_t *data);
uint8_t I2C_WriteByteToSlave(uint8_t I2C_Addr, uint8_t reg, uint8_t data);

#endif
